package com.mdb.open.trade.service.product;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mdb.bc.database.mybatisplus.SuperService;
import com.mdb.open.trade.common.MdbDataSource;
import com.mdb.open.trade.domain.po.product.CustProd;
import com.mdb.open.trade.domain.vo.product.CustProdDetailVo;
import com.mdb.open.trade.mapper.product.CustProdMapper;
import com.mdb.open.trade.mapper.product.ProductAllMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类描述：
 *  客户产品表 服务类
 *
 * @author liuyi
 * @date 2019-07-08
 */
@Service
@DS(MdbDataSource.PRODUCT)
public class CustProdService extends SuperService<CustProdMapper, CustProd> {

    @Autowired
    private ProductAllMapper productAllMapper;

    public CustProdDetailVo getCustProdDetail(String appId){
        return productAllMapper.getCustProdDetailByAppId(appId);
    }



    public List<CustProd> listByCustomerCode(String customerCode) {
        return this.list(new LambdaQueryWrapper<CustProd>().eq(CustProd::getCustomerCode, customerCode));
    }

    public CustProd getByCustProdCode(String customerCode, String prodCode) {
        return this.baseMapper.selectOne(new LambdaQueryWrapper<CustProd>()
                .eq(CustProd::getCustomerCode, customerCode)
                .eq(CustProd::getProdCode, prodCode));
    }

}
